import './index.scss';
import { Form, Input, Button } from 'antd';
import { qryCustomerInfoByCustomerId } from '@/config/request/opsManager';

const OpsCustomerTag = (props: any) => {
    const { formModal, onCallback } = props;
    const { form } = formModal;

    const getCustomerInfo = async () => {
        try {
            const params = await form.validateFields();

            console.log(params);

            const responseParam = await qryCustomerInfoByCustomerId(params);
            console.log(responseParam);
            if (responseParam.data.code === 200) {
                form.setFieldsValue({
                    customerId1: responseParam.data.data.customerId,
                    membershipFee1: responseParam.data.data.membershipFee,
                    day1: responseParam.data.data.day,
                    operatePerson: responseParam.data.data.operatePerson,
                    customerName: responseParam.data.data.customerName ?? '-',
                    superCustomerId: responseParam.data.data.superCustomerId,
                    workOrderId1: responseParam.data.data.workOrderId,
                    unificationCustomerFullName:
                        responseParam.data.data.unificationCustomerFullName ??
                        '-',
                    loginName: responseParam.data.data.loginName ?? '-',
                });

                onCallback(responseParam.data.data);
            }
        } catch (error) {
            console.log(error);
        }
    };

    return (
        <>
            <Form
                name="editOpsMemberInfo"
                labelCol={{ span: 6 }}
                wrapperCol={{ span: 14 }}
                form={form}
            >
                {/* 需求信息 */}
                <Form.Item
                    label="客户id"
                    name="customerId"
                    className="form-item-box"
                    rules={[{ required: true, message: '请输入需求名称' }]}
                >
                    <Input placeholder="请输入客户id" />
                </Form.Item>
                <Form.Item
                    label="工单编号"
                    name="workOrderId"
                    className="form-item-box"
                    rules={[{ required: true, message: '请输入' }]}
                >
                    <Input placeholder="请输入" />
                </Form.Item>
                <Form.Item>
                    <Button
                        type="primary"
                        htmlType="submit"
                        style={{ marginRight: '10%', float: 'right' }}
                        onClick={getCustomerInfo}
                    >
                        查询
                    </Button>
                </Form.Item>
                <hr />
                {/* 需求信息 */}
                <Form.Item
                    label="客户id"
                    name="customerId1"
                    className="form-item-box"
                >
                    <Input type="text" readOnly bordered={false} />
                </Form.Item>
                <Form.Item
                    label="客户名称"
                    name="customerName"
                    className="form-item-box"
                >
                    <Input type="text" readOnly bordered={false} />
                </Form.Item>
                <Form.Item
                    label="登录用户名"
                    name="loginName"
                    className="form-item-box"
                >
                    <Input type="text" readOnly bordered={false} />
                </Form.Item>
                <Form.Item
                    label="统一客户全名"
                    name="unificationCustomerFullName"
                    className="form-item-box"
                >
                    <Input type="text" readOnly bordered={false} />
                </Form.Item>
                <Form.Item
                    label="超级客户ID"
                    name="superCustomerId"
                    className="form-item-box"
                >
                    <Input type="text" readOnly bordered={false} />
                </Form.Item>
                <Form.Item
                    label="工单编号"
                    name="workOrderId1"
                    className="form-item-box"
                >
                    <Input type="text" readOnly bordered={false} />
                </Form.Item>
                <Form.Item
                    label="操作人"
                    name="operatePerson"
                    className="form-item-box"
                >
                    <Input type="text" readOnly bordered={false} />
                </Form.Item>
            </Form>
        </>
    );
};

export default OpsCustomerTag;
